import { createApp } from "vue";
import Taro from "@tarojs/taro";
import { createPinia } from "pinia";
import { SilentAuthLogin } from "./api/login";

import { USER_INFO } from "@/utils/constant";

import "./app.less";
import updateApp from "./utils/updateApp";

const App = createApp({
  async onLaunch(options) {
    console.log("onLaunch:options", options);
    // 检查是否有登录态
    if (!Taro.getStorageSync(USER_INFO)) {
      await SilentAuthLogin(false);
    }

    // 检测app 是否有更新
    updateApp();
  },
  onLoad(options) {
    console.log("onLoad:options", options);
  },
  onShow(options) {
    console.log("onShow:options", options);
  },
  // 入口组件不需要实现 render 方法，即使实现了也会被 taro 所覆盖
});

App.use(createPinia());

export default App;
